package com.unitedvision.core.domain;

import java.util.Date;

public class CompanyCustomer implements GeneralType, Debitur {
	private int id;
	private Company company;
	private Customer customer;
	private Status status;
	private long cost;
	private int debt;
	private Date joinDate;
	
	public CompanyCustomer() {
		super();
	}

	public CompanyCustomer(int id, Company company, Customer customer, Status status, long cost, int debt, Date joinDate) {
		super();
		this.id = id;
		this.company = company;
		this.customer = customer;
		this.status = status;
		this.cost = cost;
		this.debt = debt;
		this.joinDate = joinDate;
	}

	public int getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}
	
	public Company getCompany() {
		return company;
	}
	
	public void setCompany(Company company) {
		this.company = company;
	}
	
	public Customer getCustomer() {
		return customer;
	}
	
	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	
	public Status getStatus() {
		return status;
	}
	
	public void setStatus(Status status) {
		this.status = status;
	}
	
	public long getCost() {
		return cost;
	}
	
	public void setCost(long cost) {
		this.cost = cost;
	}

	public int getDebt() {
		return debt;
	}

	public void setDebt(int debt) {
		this.debt = debt;
	}

	public void setJoinDate(Date joinDate) {
		this.joinDate = joinDate;
	}

	@Override
	public Date getJoinDate() {
		return joinDate;
	}

	public String getCustomerName() {
		return customer.getName();
	}

	public CustomerType getCustomerType() {
		return customer.getType();
	}

	public Address getCustomerAddress() {
		return customer.getAddress();
	}

	public Contact getCustomerContact() {
		return customer.getContact();
	}

	public String getCompanyName() {
		return company.getName();
	}

	public Address getCompanyAddress() {
		return company.getAddress();
	}

	public Contact getCompanyContact() {
		return company.getContact();
	}
	
	public String getCompanyDescription() {
		return company.getDescription();
	}

	@Override
	public GeneralType getPayableCustomer() {
		return this;
	}

	@Override
	public String toString() {
		return "CompanyCustomer [id=" + id + ", company=" + company
				+ ", customer=" + customer + ", status=" + status + ", cost="
				+ cost + ", debt=" + debt + ", joinDate=" + joinDate + "]";
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((company == null) ? 0 : company.hashCode());
		result = prime * result + (int) (cost ^ (cost >>> 32));
		result = prime * result
				+ ((customer == null) ? 0 : customer.hashCode());
		result = prime * result + debt;
		result = prime * result + id;
		result = prime * result
				+ ((joinDate == null) ? 0 : joinDate.hashCode());
		result = prime * result + ((status == null) ? 0 : status.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CompanyCustomer other = (CompanyCustomer) obj;
		if (company == null) {
			if (other.company != null)
				return false;
		} else if (!company.equals(other.company))
			return false;
		if (cost != other.cost)
			return false;
		if (customer == null) {
			if (other.customer != null)
				return false;
		} else if (!customer.equals(other.customer))
			return false;
		if (debt != other.debt)
			return false;
		if (id != other.id)
			return false;
		if (joinDate == null) {
			if (other.joinDate != null)
				return false;
		} else if (!joinDate.equals(other.joinDate))
			return false;
		if (status != other.status)
			return false;
		return true;
	}
}
